<template>
  <!-- 支出 (财务统计)-->
  <div v-auths="['financeCount']">
    <div class="topBox">
      <p class="name">支出</p>
      <p class="tip">数据截至：{{ date }} 00:00</p>
    </div>
    <div class="list">
      <div class="itemList">
        <div class="item" style="background-color: rgba(115, 54, 244, 0.1)">
          <div class="value">
            <img
              :src="require('/public/img/expend_icon1.png')"
              alt=""
              class="img"
            />
            <p class="name">借款总额</p>
          </div>
          <p class="num">{{ countData.loanMoney }}</p>
        </div>
        <div class="item" style="background-color: rgba(115, 54, 244, 0.1)">
          <div class="value">
            <img
              :src="require('/public/img/expend_icon1.png')"
              alt=""
              class="img"
            />
            <p class="name">借款月总额</p>
          </div>
          <p class="num">{{ countData.loanMonthMoney }}</p>
        </div>
        <div class="item" style="background-color: rgba(244, 134, 54, 0.1)">
          <div class="value">
            <img
              :src="require('/public/img/expend_icon2.png')"
              alt=""
              class="img"
            />
            <p class="name">报销总额</p>
          </div>
          <p class="num">{{ countData.reimburseMoney }}</p>
        </div>
        <div class="item" style="background-color: rgba(244, 134, 54, 0.1)">
          <div class="value">
            <img
              :src="require('/public/img/expend_icon2.png')"
              alt=""
              class="img"
            />
            <p class="name">报销月总额</p>
          </div>
          <p class="num">{{ countData.reimburseMonthMoney }}</p>
        </div>
        <div class="item" style="background-color: rgba(54, 110, 244, 0.1)">
          <div class="value">
            <img
              :src="require('/public/img/expend_icon3.png')"
              alt=""
              class="img"
            />
            <p class="name">付款总额</p>
          </div>
          <p class="num">{{ countData.paymentMoney }}</p>
        </div>
        <div class="item" style="background-color: rgba(54, 110, 244, 0.1)">
          <div class="value">
            <img
              :src="require('/public/img/expend_icon3.png')"
              alt=""
              class="img"
            />
            <p class="name">付款月总额</p>
          </div>
          <p class="num">{{ countData.paymentMonthMoney }}</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { changeMoneyUnit1 } from "@/utils/changeMoneyUnit"
export default {
  name: "financeCount",
  title: "财务统计",
  icon: "el-icon-s-data",
  description: "财务统计信息展示",
  data () {
    return {
      countData: {},
      date: this.$TOOL.dateFormat(new Date(), "yyyy-MM-dd"),
    }
  },

  mounted () {
    this.getFinanceCountData()
  },
  methods: {
    async getFinanceCountData () {
      let { data } = await this.$API.finance.getFinanceCountData.get()
      this.countData = data
      this.countData.loanMoney = changeMoneyUnit1(this.countData.loanMoney)
      this.countData.loanMonthMoney = changeMoneyUnit1(this.countData.loanMonthMoney)
      this.countData.reimburseMoney = changeMoneyUnit1(this.countData.reimburseMoney)
      this.countData.reimburseMonthMoney = changeMoneyUnit1(this.countData.reimburseMonthMoney)
      this.countData.paymentMoney = changeMoneyUnit1(this.countData.paymentMoney)
      this.countData.paymentMonthMoney = changeMoneyUnit1(this.countData.paymentMonthMoney)
    },
  },
};
</script>

<style lang="scss" scoped>
.topBox {
  display: flex;
  align-items: baseline;
  margin-top: 20px;
  margin-bottom: 10px;
  .name {
    margin-right: 10px;
    font-weight: 600;
    font-size: 18px;
  }
  .tip {
    font-size: 14px;
    color: #999;
  }
}
.list {
  // margin-top: 20px;
  .itemList {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 20px;
    // overflow-x: auto;
  }
  .item {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex-basis: calc(100% / 6);
    min-width: 170px;
    height: 100px;
    padding: 0 30px;
    margin: 0 10px 10px 0;
    border-radius: 4px;
    background: #fff;
    // box-shadow: 0px 0px 11px 0px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    &:last-child {
      margin-right: 0;
    }
  }
  .value {
    display: flex;
    align-items: center;
    // margin-right: 25px;
  }
  .name {
    white-space: nowrap;
    margin-left: 10px;
    font-size: 14px;
    color: #666;
  }
  .img {
    transform: scale(0.8);
  }
  .num {
    white-space: nowrap;
    font-weight: 600;
    font-size: 18px;
    margin-top: 10px;
    margin-right: 5px;
  }
}

@media screen and (max-width: 1200px) {
  .itemList {
    flex-wrap: wrap;
    .item {
      flex-basis: calc(100% / 3 - 10px) !important;
      &:nth-child(3n) {
        margin-right: 0;
      }
    }
  }
}
</style>
